package com.zyf.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.zyf.common.result.Result;
import com.zyf.enums.OrderStatusEnum;
import com.zyf.model.order.OrderInfo;
import com.zyf.service.OrderInfoService;
import com.zyf.vo.order.OrderCountQueryVo;
import com.zyf.vo.order.OrderQueryVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

/** 后台订单管理接口
 * @author zyf
 * @date 2021年06月02日 16:49
 */
@Api(tags = "订单接口")
@RestController
@RequestMapping("/admin/order/orderInfo")
public class OrderInfoApiController {

    @Autowired
    private OrderInfoService orderInfoService;

    @ApiOperation(value = "获取分页列表")
    @GetMapping("/{page}/{limit}")
    public Result index(
            @ApiParam(name = "page", value = "当前页码", required = true)
            @PathVariable Long page,
            @ApiParam(name = "limit", value = "每页记录数", required = true)
            @PathVariable Long limit,
            @ApiParam(name = "orderCountQueryVo", value = "查询对象", required = false) OrderQueryVo orderQueryVo) {
        Page<OrderInfo> pageParam = new Page<>(page, limit);
        IPage<OrderInfo> pageModel = orderInfoService.selectPage(pageParam, orderQueryVo);
        return Result.ok(pageModel);
    }

    @ApiOperation(value = "获取订单状态")
    @GetMapping("/getStatusList")
    public Result getStatusList() {
        return Result.ok(OrderStatusEnum.getStatusList());
    }

    @ApiOperation(value = "获取订单")
    @GetMapping("/show/{id}")
    public Result get(@ApiParam(name = "orderId", value = "订单id", required = true) @PathVariable String id) {
        return Result.ok(orderInfoService.show(id));
    }

    @ApiOperation(value = "统计预约挂号数量")
    @PostMapping("/inner/Statistics")
    public Map<String, Object> selectOrderCount(@RequestBody OrderCountQueryVo orderCountQueryVo){
        System.out.println(orderCountQueryVo);
        Map<String, Object> map = orderInfoService.selectOrderCount(orderCountQueryVo);
        return map;
    }
}
